CC = g++ -Wall
RELEASE = 1
UNICODE = 0  
FILECENTOS=/etc/redhat-release
LOADBIN = -L ./NetEngine_UPDaterApp/NetEngine_Shared
LIB = -lNetEngine_BaseLib -lNetEngine_Algorithm -lNetEngine_Core -lNetEngine_ManagePool -lNetEngine_SystemApi -lNetEngine_ProcSdk -lNetHelp_APIHelp -lHelpComponents_XLog -lNetEngine_Download -lNetEngine_UPFileParser -lNetEngine_UPDownloads -lNetEngine_UPHelpModule -lNetClient_Socket
LIBEX = -static-libgcc -ldl -lrt -lpthread
LOADSO = -Wl,-rpath=./NetEngine_Shared,--disable-new-dtags
LIBINCLUDE = UPDater_Net.o UPDater_Config.o UPDater_Main.o

ifeq ($(RELEASE),1)
FLAGS = -c -O2 
DEBUG = 
else
FLAGS = -c -lc_p
DEBUG = -g -pg 
endif

ifeq ($(UNICODE),1)
UNICODE = -D _UNICODE
else
UNICODE = 
endif

ifeq ($(FILECENTOS), $(wildcard $(FILECENTOS)))
	UNICODE = -D _CENTOS
else
	UNICODE = -D _UBUNTU
endif

all:$(LIBINCLUDE)
	$(CC) $(DEBUG) $(LIBINCLUDE) -o NetEngine_UPDaterSrvApp $(LOADBIN) $(LIB) $(LIBEX) $(LOADSO)
  
UPDater_Net.o:./UPDater_Net.cpp
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./UPDater_Net.cpp
UPDater_Config.o:./UPDater_Config.cpp
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./UPDater_Config.cpp
UPDater_Main.o:./UPDater_Main.cpp             
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./UPDater_Main.cpp   


InstallAll:InstallApp
InstallApp:./NetEngine_UPDaterSrvApp
	cp -f ./NetEngine_UPDaterSrvApp ./NetEngine_UPDaterApp/NetEngine_UPDaterSrvApp
InstallSo:
	cp -f ../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_BaseLib/libNetEngine_BaseLib.so ./NetEngine_UPDaterApp/NetEngine_Shared/libNetEngine_BaseLib.so
	cp -f ../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_BaseLib/libNetEngine_Algorithm.so ./NetEngine_UPDaterApp/NetEngine_Shared/libNetEngine_Algorithm.so
	cp -f ../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_Core/libNetEngine_Core.so ./NetEngine_UPDaterApp/NetEngine_Shared/libNetEngine_Core.so
	cp -f ../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_Core/libNetEngine_ManagePool.so ./NetEngine_UPDaterApp/NetEngine_Shared/libNetEngine_ManagePool.so
	cp -f ../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_HelpComponents/libHelpComponents_XLog.so ./NetEngine_UPDaterApp/NetEngine_Shared/libHelpComponents_XLog.so
	cp -f ../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_DownLoad/libNetEngine_Download.so ./NetEngine_UPDaterApp/NetEngine_Shared/libNetEngine_Download.so
	cp -f ../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_SystemSdk/libNetEngine_ProcSdk.so ./NetEngine_UPDaterApp/NetEngine_Shared/libNetEngine_ProcSdk.so
	cp -f ../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_SystemSdk/libNetEngine_SystemApi.so ./NetEngine_UPDaterApp/NetEngine_Shared/libNetEngine_SystemApi.so
	cp -f ../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_NetHelp/libNetHelp_APIHelp.so ./NetEngine_UPDaterApp/NetEngine_Shared/libNetHelp_APIHelp.so
	cp -f ../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_DownLoad/libNetEngine_Download.so ./NetEngine_UPDaterApp/NetEngine_Shared/libNetEngine_Download.so
	cp -f ../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_UPData/libNetEngine_UPDownloads.so ./NetEngine_UPDaterApp/NetEngine_Shared/libNetEngine_UPDownloads.so
	cp -f ../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_UPData/libNetEngine_UPFileParser.so ./NetEngine_UPDaterApp/NetEngine_Shared/libNetEngine_UPFileParser.so
	cp -f ../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_UPData/libNetEngine_UPHelpModule.so ./NetEngine_UPDaterApp/NetEngine_Shared/libNetEngine_UPHelpModule.so
	cp -f ../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_Client/libNetClient_Socket.so ./NetEngine_UPDaterApp/NetEngine_Shared/libNetClient_Socket.so
CleanAll:CleanObj CleanMk
CleanObj:                                              
	rm *.o
CleanMk:                                  
	rm NetEngine_UPDaterSrvApp     
CleanSo:
	rm ./NetEngine_UPDaterApp/NetEngine_UPDaterSrvApp
	rm ./NetEngine_UPDaterApp/NetEngine_Shared/*.so
	       
